package com.lei.lib_croe.http.observ;

import com.lei.lib_croe.http.bean.BaseDataBean;
import com.lei.lib_croe.http.bean.ErrorBean;

import io.reactivex.observers.DisposableObserver;

public abstract class CallObserver<T extends BaseDataBean> extends DisposableObserver<T> implements IObserver<T> {

    @Override
    public void onNext(T t) {
        if (t.getCode() == 200) {
            success(t);
        }else {
            fail(new ErrorBean(t.getCode(), t.getMsg()));
        }
    }

    @Override
    public void onError(Throwable e) {
        fail(new ErrorBean(-200, e.getMessage()));
    }

    @Override
    public void onComplete() {

    }

    @Override
    public void fail(ErrorBean errorBean) {

    }
}
